//
//  TabBarViewController.swift
//  赞阅__老师端
//
//  Created by caimengnan on 2017/12/11.
//  Copyright © 2017年 zabyue. All rights reserved.
//

import UIKit

class TabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        setUpChildVC()
    }

    private func setUpChildVC() {
        
        //首页
        let homeVC = HomePageViewController()
        self.addChildVIewController(homeVC, title: "首页", image: "", selectedImage: "")
        
        //跟名家学语文
        let learn = LearnChineseWithTeacherController()
        self.addChildVIewController(learn, title: "跟名家学语文", image: "", selectedImage: "")
        
        //亲子共读
        let read = ParentChildReadingController()
        self.addChildVIewController( read, title: "亲子共读", image: "", selectedImage: "")
        
        //班级之家
        let classHome = ClassHomeController()
        self.addChildVIewController(classHome, title: "班级之家", image: "", selectedImage: "")
        
        //学习资源
        let source = SourceOfStudyController()
        self.addChildVIewController(source, title: "学习资源", image: "", selectedImage: "")
    
    }
    
    
    private func addChildVIewController(_ viewController:UIViewController,title: String,image: String,selectedImage: String) {
        
        let nav = BaseNavController.init(rootViewController: viewController)
        nav.tabBarItem.title = title
        nav.tabBarItem.image = UIImage(named:image)
        nav.tabBarItem.selectedImage = UIImage(named:selectedImage)?.withRenderingMode(.alwaysOriginal)
        nav.tabBarItem.setTitleTextAttributes([NSAttributedStringKey.foregroundColor:UIColor.green], for: .selected)
        nav.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 2, vertical: -4)
        self.addChildViewController(nav)
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    
}
